package cn.hxzy.servlet.admin;

import cn.hxzy.dao.UserDao;
import cn.hxzy.entity.User;
import cn.hxzy.service.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/admin/deleteUser")
public class ShowUserDeleteServlet extends HttpServlet {
    UserService userService=new UserService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            String id = req.getParameter("id");
            String[] split = id.split(",");
            for (String s : split) {
                userService.delete(Integer.parseInt(s));
            }
            resp.sendRedirect("showUser");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
